package 树;

public class Demo06 {
    static class Solution {
        TreeNode preNode = null;
        public void flatten(TreeNode root) {
            if(root == null){
                return;
            }
            TreeNode rightTree = root.right;

            if(preNode == null){
                preNode = root;
            }else{
                preNode.right = root;
                preNode = preNode.right;
            }

            flatten(root.left);
            root.left = null;
            flatten(rightTree);
        }

    }
}
